home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Controls / Visual Basic Controls.iso / vbcontrol / spchauto / data1.cab / Samples / Visual_C++ / Editor / MfcSpell.h < prev    next >
Encoding:
C/C++ Source or Header  |  1999-07-16  |  5.4 KB  |  207 lines

  1. // MFCSPELL.H
  2. //
  3. // Copyright (c) 1999 by POLAR.  All Rights Reserved.
  4. //
  5. // mfcspell.h - MFC wrapper for POLSPELL.DLL (user accessible classes)
  6. //
  7. //
  8.  
  9.  
  10. #ifndef __POLMFCSPELL_H
  11. #define __POLMFCSPELL_H
  12.  
  13.  
  14. #include "polspell.h"
  15.  
  16. // TSpellingChecker - MFC wrapper for POLSPELL.DLL API-s (all functions must be inline)
  17.  
  18. class TSpellingChecker
  19. {
  20.  private:
  21.     HSPELL m_hSpell;
  22.  
  23.  public:
  24.    TSpellingChecker();
  25.    ~TSpellingChecker();
  26.  
  27.    BOOL OpenDictionary(LPCTSTR pszMainDictFileName, LPCTSTR pszCustomDictFileName);
  28.    void CloseDictionary();
  29.    BOOL Reset();
  30.    CString GetLanguageName(LPCTSTR pszDictFileName);
  31.    BOOL IsWordExist(LPCTSTR pszWord);
  32.    void AddToChangeAll(LPCTSTR pszFind, LPCTSTR pszReplace);
  33.    void AddToIgnoreAll(LPCTSTR pszWord);
  34.    BOOL IsCharAlpha(short ch);
  35.    BOOL IsCharLower(short ch);
  36.    BOOL IsCharUpper(short ch);
  37.    CString GetReplacement(LPCTSTR pszWord);
  38.    CString GetSuggestion(LPCTSTR pszWord, short nSuggestionIndex);
  39.    void AddWord(LPCTSTR pszNewWord);
  40.    CString CheckText(LPCTSTR pszText, short *pnExitStatus);
  41.    BOOL GetAlwaysSuggest();
  42.    void SetAlwaysSuggest(BOOL bNewValue);
  43.    BOOL GetIgnoreWordsInUppercase();
  44.    void SetIgnoreWordsInUppercase(BOOL bNewValue);
  45.    BOOL GetIgnoreWordsWithNumbers();
  46.    void SetIgnoreWordsWithNumbers(BOOL bNewValue);
  47.    BOOL DownloadDictionaries(LPCTSTR pszUpdateURL, LPCTSTR pszInstallDir);
  48.    BOOL OptionsDialog(LPCTSTR pszDictionaryDir, LPTSTR pszCustomDicFileName, unsigned nCustomDicSize,
  49.                       LPTSTR pszCurDicFileName, unsigned nCurDicSize, LPCTSTR pszURL, BOOL bInternetSupport);
  50. };
  51.  
  52.  
  53. ////////////////////////////////////////////////////////////////////////////////
  54. // Inline functions
  55.  
  56.  
  57. inline TSpellingChecker::TSpellingChecker()
  58. {
  59.    m_hSpell = PS_Init();
  60. }
  61.  
  62. inline TSpellingChecker::~TSpellingChecker()
  63. {
  64.    PS_Destroy(m_hSpell);
  65. }
  66.  
  67. inline BOOL TSpellingChecker::OpenDictionary(LPCTSTR pszMainDictFileName, LPCTSTR pszCustomDictFileName)
  68. {
  69.    return PS_OpenDictionary(m_hSpell, pszMainDictFileName, pszCustomDictFileName);
  70. }
  71.  
  72. inline void TSpellingChecker::CloseDictionary()
  73. {
  74.    PS_CloseDictionary(m_hSpell);
  75. }
  76.  
  77. inline BOOL TSpellingChecker::Reset()
  78. {
  79.    return PS_Reset(m_hSpell);
  80. }
  81.  
  82. inline CString TSpellingChecker::GetLanguageName(LPCTSTR pszDictFileName)
  83. {
  84.    CString strLang;
  85.  
  86.    PS_GetLanguageName(m_hSpell, pszDictFileName, strLang.GetBuffer(256), 256-1);
  87.    strLang.ReleaseBuffer();
  88.  
  89.    return strLang;
  90. }
  91.  
  92. inline BOOL TSpellingChecker::IsWordExist(LPCTSTR pszWord)
  93. {
  94.    return PS_IsWordExist(m_hSpell, pszWord);
  95. }
  96.  
  97. inline void TSpellingChecker::AddToChangeAll(LPCTSTR pszFind, LPCTSTR pszReplace)
  98. {
  99.    PS_AddToChangeAll(m_hSpell, pszFind, pszReplace);
  100. }
  101.  
  102. inline void TSpellingChecker::AddToIgnoreAll(LPCTSTR pszWord)
  103. {
  104.    PS_AddToIgnoreAll(m_hSpell, pszWord);
  105. }
  106.  
  107. inline BOOL TSpellingChecker::IsCharAlpha(short ch)
  108. {
  109.    return PS_IsCharAlpha(m_hSpell, ch);
  110. }
  111.  
  112. inline BOOL TSpellingChecker::IsCharLower(short ch)
  113. {
  114.    return PS_IsCharLower(m_hSpell, ch);
  115. }
  116.  
  117. inline BOOL TSpellingChecker::IsCharUpper(short ch)
  118. {
  119.    return PS_IsCharUpper(m_hSpell, ch);
  120. }
  121.  
  122. inline CString TSpellingChecker::GetReplacement(LPCTSTR pszWord)
  123. {
  124.    CString strResult;
  125.  
  126.    PS_GetReplacement(m_hSpell, pszWord, strResult.GetBuffer(256), 256-1);
  127.    strResult.ReleaseBuffer();
  128.    return strResult;
  129. }
  130.  
  131. inline CString TSpellingChecker::GetSuggestion(LPCTSTR pszWord, short nSuggestionIndex)
  132. {
  133.    CString strResult;
  134.  
  135.    PS_GetSuggestion(m_hSpell, pszWord, nSuggestionIndex, strResult.GetBuffer(256), 256-1);
  136.    strResult.ReleaseBuffer();
  137.    return strResult;
  138. }
  139.  
  140. inline void TSpellingChecker::AddWord(LPCTSTR pszNewWord)
  141. {
  142.    PS_AddWord(m_hSpell, pszNewWord);
  143. }
  144.  
  145. inline CString TSpellingChecker::CheckText(LPCTSTR pszText, short *pnExitStatus)
  146. {
  147.    CString strResult;
  148.  
  149.    strResult.Empty();
  150.    HGLOBAL hglb = PS_CheckText(m_hSpell, pszText, pnExitStatus);
  151.    if(hglb)
  152.    {
  153.       LPTSTR psz = (LPTSTR)GlobalLock(hglb);
  154.       if(psz)
  155.       {
  156.          strResult = psz;
  157.          GlobalUnlock(hglb);
  158.       }
  159.       GlobalFree(hglb);
  160.    }
  161.    return strResult;
  162. }
  163.  
  164. inline BOOL TSpellingChecker::GetAlwaysSuggest()
  165. {
  166.    return PS_GetAlwaysSuggest(m_hSpell);
  167. }
  168.  
  169. inline void TSpellingChecker::SetAlwaysSuggest(BOOL bNewValue)
  170. {
  171.    PS_SetAlwaysSuggest(m_hSpell, bNewValue);
  172. }
  173.  
  174. inline BOOL TSpellingChecker::GetIgnoreWordsInUppercase()
  175. {
  176.    return PS_GetIgnoreWordsInUppercase(m_hSpell);
  177. }
  178.  
  179. inline void TSpellingChecker::SetIgnoreWordsInUppercase(BOOL bNewValue)
  180. {
  181.    PS_SetIgnoreWordsInUppercase(m_hSpell, bNewValue);
  182. }
  183.  
  184. inline BOOL TSpellingChecker::GetIgnoreWordsWithNumbers()
  185. {
  186.    return PS_GetIgnoreWordsWithNumbers(m_hSpell);
  187. }
  188.  
  189. inline void TSpellingChecker::SetIgnoreWordsWithNumbers(BOOL bNewValue)
  190. {
  191.    PS_SetIgnoreWordsWithNumbers(m_hSpell, bNewValue);
  192. }
  193.  
  194. inline BOOL TSpellingChecker::DownloadDictionaries(LPCTSTR pszUpdateURL, LPCTSTR pszInstallDir)
  195. {
  196.    return PS_DownloadDictionaries(m_hSpell, pszUpdateURL, pszInstallDir);
  197. }
  198.  
  199. inline BOOL TSpellingChecker::OptionsDialog(LPCTSTR pszDictionaryDir, LPTSTR pszCustomDicFileName,
  200.                                             unsigned nCustomDicSize, LPTSTR pszCurDicFileName,
  201.                                                           unsigned nCurDicSize, LPCTSTR pszURL, BOOL bInternetSupport)
  202. {
  203.    return PS_OptionsDialog(m_hSpell, pszDictionaryDir, pszCustomDicFileName, nCustomDicSize, pszCurDicFileName,
  204.                             nCurDicSize, pszURL, bInternetSupport);
  205. }
  206.  
  207. #endif